//
//  DoctorApplyCell.m
//  项目唯一
//
//  Created by 谌桃 on 16/7/6.
//  Copyright © 2016年 ryan.chen. All rights reserved.
//

#import "DoctorApplyCell.h"

@interface DoctorApplyCell()

@property (nonatomic, strong) DoctorLabel *lab1; //王先生
@property (nonatomic, strong) DoctorLabel *lab2; //颈椎病
@property (nonatomic, strong) DoctorLabel *lab3; //就诊时间
@property (nonatomic, strong) DoctorLabel *lab4; //王医师
@property (nonatomic, strong) DoctorLabel *lab5; //主任医师
@property (nonatomic, strong) DoctorLabel *lab6; //医院
@property (nonatomic, strong) DoctorLabel *lab7; //审核中

//线
@property (nonatomic, strong) UIView * lineV;

@end

@implementation DoctorApplyCell

- (instancetype)initWithFrame:(CGRect)frame{

    self = [super initWithFrame:frame];
    if (self) {
        [self setupUI];
    }
    
    return self;
}


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{

    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        [self setupUI];
    }
    
    return self;
}

#pragma 设置UI
- (void)setupUI{

    [self addSubview:self.lab1];
    [self addSubview:self.lab2];
    [self addSubview:self.lab3];
    [self addSubview:self.lab4];
    [self addSubview:self.lab5];
    [self addSubview:self.lab6];
    [self addSubview:self.lab7];
    [self addSubview:self.lineV];
    
    /*!
     *  约束控件
     */
    
    CGFloat offsetY = 20;
    
    CGFloat offsetX = 5;
    
    CGFloat offsetRight = 30;
    
    if (kDevice_Is_iPhone5) {
        
        offsetX = 2;
        offsetRight = 10;
        
    }
    
    [self.lab7 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.size.mas_equalTo(CGSizeMake(60, 60));
        make.centerY.mas_equalTo(self.mas_centerY);
        make.right.mas_equalTo(self).offset(-offsetRight);
        
    }];
    
    [self.lineV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(1);
        make.left.mas_equalTo(15);
        make.right.mas_equalTo(self.lab7.mas_left);
        make.centerY.mas_equalTo(self.mas_centerY);
        
    }];
    [self.lab1 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.height.mas_equalTo(40);
        make.left.mas_equalTo(10);
        make.centerY.mas_equalTo(self.mas_centerY).offset(-offsetY);
        
    }];
    [self.lab2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.lab1.mas_right).offset(offsetX);
        make.height.mas_equalTo(40);
        make.bottom.mas_equalTo(self.lab1.mas_bottom);
        
    }];
    [self.lab3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.lab2.mas_right);
        make.height.mas_equalTo(40);
        make.bottom.mas_equalTo(self.lab1.mas_bottom);
        make.right.mas_equalTo(self.lineV.mas_right);
        
    }];
    
    [self.lab4 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(40);
        make.left.mas_equalTo(10);
        make.centerY.mas_equalTo(self.mas_centerY).offset(offsetY);
        
    }];
    
    [self.lab5 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.lab4.mas_right).offset(offsetX);
        make.height.mas_equalTo(40);
        make.bottom.mas_equalTo(self.lab4.mas_bottom);
        
    }];
    
    [self.lab6 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.lab5.mas_right);
        make.height.mas_equalTo(40);
        make.bottom.mas_equalTo(self.lab4.mas_bottom);
        make.right.mas_equalTo(self.lineV.mas_right);
        
        
    }];

}

#pragma 重写set方法
- (void)setDto:(DoctorApplyDTO *)dto{

    _dto = dto;
    self.lab1.text = dto.name;
    self.lab2.text = dto.caseString;
    self.lab3.text = dto.cureTimeString;
    self.lab4.text = dto.doctor;
    self.lab5.text = dto.doctor_calss;
    self.lab6.text = dto.hospitol;
    self.lab7.text = dto.cureState;
}

#pragma Lazy
- (DoctorLabel *)lab1{

    if (!_lab1) {
        _lab1 = [[DoctorLabel alloc] init];
        _lab1.textAlignment = NSTextAlignmentCenter;
    }
    return _lab1;
}

- (DoctorLabel *)lab2{
    
    if (!_lab2) {
        _lab2 = [[DoctorLabel alloc] init];
        _lab2.textAlignment = NSTextAlignmentCenter;
    }
    return _lab2;
}

- (DoctorLabel *)lab3{
    
    if (!_lab3) {
        _lab3 = [[DoctorLabel alloc] init];
        _lab3.textAlignment = NSTextAlignmentCenter;
    }
    return _lab3;
}

- (DoctorLabel *)lab4{
    
    if (!_lab4) {
        _lab4 = [[DoctorLabel alloc] init];
        _lab4.textAlignment = NSTextAlignmentCenter;
    }
    return _lab4;
}

- (DoctorLabel *)lab5{
    
    if (!_lab5) {
        _lab5 = [[DoctorLabel alloc] init];
        _lab5.textAlignment = NSTextAlignmentCenter;
    }
    return _lab5;
}

- (DoctorLabel *)lab6{
    
    if (!_lab6) {
        _lab6 = [[DoctorLabel alloc] init];
        _lab6.textAlignment = NSTextAlignmentCenter;
    }
    return _lab6;
}

- (DoctorLabel *)lab7{
    
    if (!_lab7) {
        _lab7 = [[DoctorLabel alloc] init];
        _lab7.textAlignment = NSTextAlignmentCenter;
        _lab7.backgroundColor = kThemeColor;
        _lab7.layer.masksToBounds = YES;
        _lab7.layer.cornerRadius = 30;
    }
    return _lab7;
}

- (UIView *)lineV{

    if (!_lineV) {
        _lineV = [[UIView alloc] init];
        _lineV.backgroundColor = RGBCOLOR(39, 96, 130);
    }
    return _lineV;
}



@end
